<?php
$current=1;
if (isset($_GET['cur'])) {
    $current=$_GET['cur'];
}
$rowNum=10;
$startId=($current-1) * $rowNum;
$rowCount=0;
?><!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1">
<title>专属活动链接申请</title>
<link rel="stylesheet" href="weui.min.css"/>
<link rel="stylesheet" href="./js/paging.css"/>
<style>
.page{display:block;}
.user-info{width:100%;font-size:12px;margin-top:60px;}
.ul{
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    height: 100%;
    box-sizing: border-box;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -webkit-flex-direction: column;
    flex-direction: column;
}
.thelist{
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    position: relative;
    z-index: 500;
}
.li{
    position: relative;
    display: block;
    width: 80px;
    height: 80px;
    -webkit-box-flex: 1;
    -webkit-flex: 1;
    flex: 1;
    overflow: hidden;
    text-align: center;
    font-size: 12px;
    line-height: 80px;
    border-right: 1px solid rgba(0,0,0,.1);
    border-bottom: 1px solid rgba(0,0,0,.1);
}
.li:after{
    position: absolute;
    right: 0;
    top: 0;
    width: 1px;
    bottom: 0;
    
}
.li-header{
    border-top: 1px solid rgba(0,0,0,.1);
    background: #4472c4;
    color: #fff;
}
#pageTool{width:100%;height: 90px;margin-top: 60px;}
</style></head>
<body>
<?php
$id=1;
if (isset($_GET['id'])) {
    $id=$_GET['id'];
}
$tabActive=array(
    '1' => '', 
    '2' => '', 
    '3' => '',
    '4' => '',
    '5' => '',
    '6' => '',
);
$tabActive[$id]='weui-bar__item_on';
$zslink=4;



include '../c/config.php';
$mysqli = new mysqli($dbhost, $dbuser, $dbpwd, $dbName);
?>
 <div class="page navbar js_show" tabindex="-1">
    <div class="page__bd" style="height: 100%;">
        <div class="weui-tab">
            <div class="weui-navbar">
                <div class="weui-navbar__item <?php echo $tabActive[1]; ?> tabbar" data-id='1'>
                    裂变流量数据
                </div>
                <div class="weui-navbar__item <?php echo $tabActive[2]; ?> tabbar" data-id='2'>
                    流量数据细分
                </div>
                <div class="weui-navbar__item <?php echo $tabActive[3]; ?> tabbar"  data-id='3'>
                    用户数据
                </div>
                <div class="weui-navbar__item <?php echo $tabActive[4]; ?> tabbar"  data-id='4'>
                    总数据
                </div>
                <div class="weui-navbar__item <?php echo $tabActive[5]; ?> tabbar"  data-id='5'>
                    事件
                </div>
                <div class="weui-navbar__item <?php echo $tabActive[6]; ?> tabbar"  data-id='6'>
                    图标跳出
                </div>
            </div>
        </div>
    </div>
</div>

<?php if(1 == $id){  ?>
<div class="user-info">
        <div class="ul">
            <div class="thelist li-header">
                <div class="li">
                    链接
                </div>
                <div class="li">
                    一级流量PV
                </div>
                <div class="li">
                    一级流量UV
                </div>
                <div class="li">
                    二级流量PV
                </div>
                <div class="li">
                    二级流量UV
                </div>
                <div class="li">
                    三级流量PV
                </div>
                <div class="li">
                    三级流量UV
                </div>
                <div class="li">
                    日期
                </div>
            </div>
<?php 
$jiBie= array(
    '1' => '一级', 
    '2' => '二级',
    '3' => '三级'
);
      $query=$mysqli->query("select * from zsu_lie_tong  ");
      while ($getD = $query->fetch_assoc()) {
    
?>
            <div class="thelist">
                <div class="li">
                    climb-game.51wom.com/?zslink=<?php echo $getD['zslink']; ?>
                </div>
                 
                <div class="li">
                    <?php echo $getD['pv1']; ?>
                </div>
                <div class="li">
                    <?php echo $getD['uv1']; ?>
                </div>
                <div class="li">
                    <?php echo $getD['pv2']; ?>
                </div>
                <div class="li">
                    <?php echo $getD['uv2']; ?>
                </div>
                <div class="li">
                    <?php echo $getD['pv3']; ?>
                </div>
                <div class="li">
                    <?php echo $getD['uv3']; ?>
                </div>
               
                 
                <div class="li">
                   <?php echo $getD['theday']; ?>
                </div>
            </div>
<?php } 

?>
             
             
        </div>
   
</div>
<?php  } ?>

<?php if(2 == $id){  ?>
<div class="user-info">
        <div class="ul">
            <div class="thelist li-header">
                <div class="li">
                    流量等级
                </div>
                <div class="li">
                    受访页面URL
                </div>
                <div class="li">
                    页面浏览量
                </div>
                <div class="li">
                    页面用户数
                </div>
                <div class="li">
                    页面访问时长
                </div>
                <div class="li">
                    退出率
                </div>
                <div class="li">
                    日期
                </div>
            </div>
<?php 
$jiBie= array(
    '1' => '一级', 
    '2' => '二级',
    '3' => '三级'
);
      $query=$mysqli->query("select * from zsu_pvuv_tong  ");
      while ($getD = $query->fetch_assoc()) {
          
?>
            <div class="thelist">
                <div class="li">
                    <?php echo $jiBie[$getD['ji']]; ?>
                </div>
                <div class="li">
                    climb-game.51wom.com/?zslink=<?php echo $getD['zslink']; ?>
                </div>
                <div class="li">
                    <?php echo $getD['pv']; ?>
                </div>
                <div class="li">
                    <?php echo $getD['uv']; ?>
                </div>
                <div class="li">
                    <?php echo $getD['fwen_time']; ?>
                </div>
                <div class="li">
                   <?php echo $getD['loginout_rate']; ?>
                </div>
                <div class="li">
                   <?php echo $getD['theday']; ?>
                </div>
            </div>
<?php } 

?>
             
             
        </div>
   
</div>
<?php  } ?>


<?php if(3 == $id){  ?>
<div class="user-info">
        <div class="ul">
            <div class="thelist li-header">
                <div class="li">手机号码</div>
                <div class="li">页面浏览量</div>
                <div class="li">游戏分数</div>
                <div class="li">排名</div>
                <div class="li">如有邀请人(NC/PNEC) Phone</div>
            </div>
<?php 
      
      
      $queryC=$mysqli->query("select count(id) as count from zsu_phone_tong  ");
      $getCount=$queryC->fetch_assoc();
      $rowCount=$getCount['count'];
      
      $i=1 + $startId;

      $query=$mysqli->query("select * from zsu_phone_tong order by fen desc limit ".$startId.",".$rowNum." ");
      while ($getD=$query->fetch_assoc()) {
          $zsPhone='';
          if ($getD['zslink'] > 0) {
               $queryZs=$mysqli->query("select phone from zuansu_user where id='".$getD['zslink']."' ");
               $getZs=$queryZs->fetch_assoc();
               if (isset($getZs['phone'])) {
                  $zsPhone=$getZs['phone'];
               }
               

          }

?>
               <div class="thelist">
                <div class="li">
                    <?php echo $getD['phone']; ?>
                </div>
                <div class="li">
                    <?php echo $getD['pv']; ?>
                </div>
                <div class="li">
                    <?php echo $getD['fen']; ?>
                </div>
                <div class="li">
                    <?php echo $i;  ?>
                </div>
                <div class="li">
                   <?php  echo $zsPhone; ?>
                </div>
            </div>
<?php  

$i++;
} ?>    
        </div>
</div>
<?php  } ?>


<?php if(4 == $id){  ?>
<div class="user-info">
        <div class="ul">
            <div class="thelist li-header">
                <div class="li">日期</div>
                <div class="li">手机号码</div>
                <div class="li">邀新人数</div>
                <div class="li">登入人数</div>
                <div class="li" style="line-height:40px;">邀请用户参与<br/>登山小游戏人数</div>
            </div>
<?php 
      $queryC=$mysqli->query("select count(id) as count from zsu_total_tong  ");
      $getCount=$queryC->fetch_assoc();
      $rowCount=$getCount['count'];
       
      $query=$mysqli->query("select * from zsu_total_tong   limit ".$startId.",".$rowNum." ");
      if($query->num_rows>0){
      while ($list=$query->fetch_assoc()) {
?>
               <div class="thelist">
                <div class="li">
                    <?php echo $list['theday']; ?>
                </div>
                <div class="li">
                    <?php echo $list['phone']; ?>
                </div>
                <div class="li">
                    <?php echo $list['newuser']; ?>
                </div>
                <div class="li">
                    <?php echo $list['lognuser']; ?>
                </div>
                 
                <div class="li">
                   <?php echo $list['gameuser']; ?>
                </div>
            </div>
<?php  }} ?>    
        </div>
</div>
<?php  } ?>


<?php if(5 == $id){  

$eventName=array(
    'gonggaoclose' =>  array('txt' => '公告栏-进入按钮', 'a'=>'点击'),
    'zhibojian' =>  array('txt' => '游戏界面-直播间', 'a'=>'点击'),
    'viewpaihangbang' =>  array('txt' => '游戏界面-排行榜', 'a'=>'点击'),
    'gamegonggao'=> array('txt' => '游戏界面-公告', 'a'=>'点击'),
    'startgame' => array('txt' => '游戏准备-开始按钮', 'a'=>'点击')
);
?>
<div class="user-info">
        <div class="ul">
            <div class="thelist li-header">
                <div class="li">事件分类</div>
                <div class="li">事件动作</div>
                <div class="li">事件用户数</div>
                <div class="li">事件次数</div>
            </div>
<?php 

      
      
foreach ($eventName as $key => $value) {
 
      $query=$mysqli->query("select count(distinct(openid)) as count from zsu_click_log where lei='".$key."'   ");
      $getUser=$query->fetch_assoc();
      $query=$mysqli->query("select count(id) as count from zsu_click_log where lei='".$key."'    ");
      $getCount=$query->fetch_assoc();
   
?>
               <div class="thelist">
                <div class="li">
                    <?php echo $value['txt']; ?>
                </div>
                <div class="li">
                    <?php echo $value['a']; ?>
                </div>
                <div class="li">
                    <?php echo $getUser['count']; ?>
                </div>
                <div class="li">
                    <?php echo $getCount['count']; ?>
                </div>
                
            </div>
<?php  
} 
?>

        </div>
</div>
<?php  } ?>



<?php if(6 == $id){  

$eventName=array(
     1=>'细菌',
     2=>'易生病',
     3=>'病毒',
     4=>'大脑',
     5=>'肠胃'
    
);
?>
<div class="user-info">
        <div class="ul">
            <div class="thelist li-header">
                <div class="li">时间</div>
                <div class="li">图标名称</div>
                <div class="li">跳出次数</div>
            </div>
<?php 

 
      $query=$mysqli->query("select * from zsu_xijun_tong ");
      while ($list=$query->fetch_assoc()) {

       
?>
            <div class="thelist">
                <div class="li">
                    <?php echo $list['theday']; ?>
                </div>
                <div class="li">
                    <?php echo $eventName[$list['lei']]; ?>
                </div>
                <div class="li">
                    <?php echo $list['ci']; ?>
                </div>
                 
                
            </div>
<?php  
} 
?>

        </div>
</div>
<?php  } ?>


<div id="pageTool"></div>

<script src="https://lf26-cdn-tos.bytecdntp.com/cdn/expire-1-M/jquery/3.0.0/jquery.min.js"></script>
<script src="https://res.wx.qq.com/t/wx_fed/cdn_libs/res/weui/1.2.5/weui.min.js"></script>
<script src="./js/paging.js"></script>
<script type="text/javascript">
$(function(){

  $(".tabbar").click(function(){
      var _id=$(this).attr("data-id");
      window.location.href="?id="+_id;
  });
  
  <?php if ($rowCount > 0) { ?>
  var p = new Paging();
p.init({target:'#pageTool',pagesize:<?php echo $rowNum; ?>,count:<?php echo $rowCount; ?>,current:<?php echo $current; ?>,callback:function(pagecount,size,count){
   console.log('当前第 ' + pagecount + '页,每页 ' + size + '条,总页数：' + count + '页');

   window.location.href="?id=<?php echo $id; ?>&cur="+pagecount;

}});

<?php } ?>
 

});    
</script>

</body>
</html>